/*
*---------------------------------------------------------------
*                        Lvgl Font Tool                         
*                                                               
* 注:使用unicode编码                                              
* 注:本字体文件由Lvgl Font Tool V0.4 生成                          
* 作者:阿里(qq:617622104)                                         
*---------------------------------------------------------------
*/

#ifdef LV_LVGL_H_INCLUDE_SIMPLE
#include "lvgl.h"
#else
#include "../lvgl/lvgl.h"
#endif


typedef struct{
    uint16_t min;
    uint16_t max;
    uint8_t  bpp;
    uint8_t  reserved[3];
}x_header_t;
typedef struct{
    uint32_t pos;
}x_table_t;
typedef struct{
    uint8_t adv_w;
    uint8_t box_w;
    uint8_t box_h;
    int8_t  ofs_x;
    int8_t  ofs_y;
    uint8_t r;
}glyph_dsc_t;


static const uint8_t glyph_dsc_xbf[] = {

0x03,0x21,0x03,0x21,0x04,0x00,0x00,0x00,//xbf header

0x0c,0x00,0x00,0x00,//0x2103

/* ℃ */
33,34,27,0,11,0,  //dsc : unicode = 0x2103
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  //......+...................+++....
0x00,0x02,0x9d,0xee,0xa4,0x00,0x00,0x00,0x00,0x00,0x03,0x8b,0xde,0xff,0xed,0xb8,0x30,  //...+%@@@%*...........+%%@@@@@@@%+
0x00,0x5e,0xff,0xff,0xff,0xa0,0x00,0x00,0x00,0x04,0xcf,0xff,0xff,0xff,0xff,0xff,0x90,  //..*@@@@@@@%+.......*@@@@@@@@@@@@%
0x05,0xff,0xff,0xff,0xff,0xf9,0x00,0x00,0x00,0x7e,0xff,0xff,0xff,0xff,0xff,0xff,0x90,  //.*@@@@@@@@@%......%@@@@@@@@@@@@@%
0x0d,0xff,0xfd,0xab,0xff,0xff,0x40,0x00,0x06,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x90,  //+@@@@@%@@@@@*....*@@@@@@@@@@@@@@%
0x5f,0xff,0xb0,0x00,0x6f,0xff,0xa0,0x00,0x3e,0xff,0xff,0xe9,0x41,0x00,0x02,0x58,0x70,  //*@@@%+..*@@@%...+@@@@@@%*+++++*%*
0x8f,0xff,0x20,0x00,0x0c,0xff,0xd0,0x00,0xaf,0xff,0xfd,0x30,0x00,0x00,0x00,0x00,0x00,  //%@@@+....@@@@...%@@@@@+..........
0x9f,0xff,0x00,0x00,0x0a,0xff,0xe0,0x02,0xef,0xff,0xf4,0x00,0x00,0x00,0x00,0x00,0x00,  //%@@@+....%@@@..+@@@@@*...........
0x8f,0xff,0x40,0x00,0x1e,0xff,0xd0,0x06,0xff,0xff,0xb0,0x00,0x00,0x00,0x00,0x00,0x00,  //%@@@*...+@@@@..*@@@@@............
0x3f,0xff,0xd4,0x02,0xbf,0xff,0x80,0x0a,0xff,0xff,0x60,0x00,0x00,0x00,0x00,0x00,0x00,  //*@@@@*++@@@@%..%@@@@*............
0x0b,0xff,0xff,0xff,0xff,0xfe,0x10,0x0c,0xff,0xff,0x30,0x00,0x00,0x00,0x00,0x00,0x00,  //.@@@@@@@@@@@+..@@@@@+............
0x01,0xdf,0xff,0xff,0xff,0xe5,0x00,0x0e,0xff,0xff,0x10,0x00,0x00,0x00,0x00,0x00,0x00,  //.+@@@@@@@@@*...@@@@@+............
0x00,0x1b,0xff,0xff,0xfd,0x40,0x00,0x0f,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  //..+%@@@@@@*...+@@@@@+............
0x00,0x00,0x37,0x98,0x50,0x00,0x00,0x0f,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  //....+%%%*+....+@@@@@+............
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0f,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  //..............+@@@@@+............
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0e,0xff,0xff,0x10,0x00,0x00,0x00,0x00,0x00,0x00,  //...............@@@@@+............
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0d,0xff,0xff,0x30,0x00,0x00,0x00,0x00,0x00,0x00,  //...............@@@@@+............
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0b,0xff,0xff,0x50,0x00,0x00,0x00,0x00,0x00,0x00,  //...............%@@@@*............
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0xff,0xff,0xa0,0x00,0x00,0x00,0x00,0x00,0x00,  //...............%@@@@%............
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0xff,0xff,0xe2,0x00,0x00,0x00,0x00,0x00,0x00,  //...............*@@@@@+...........
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xdf,0xff,0xfc,0x10,0x00,0x00,0x00,0x00,0x00,  //...............+@@@@@@+..........
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x6f,0xff,0xff,0xd7,0x31,0x00,0x12,0x48,0xa0,  //................*@@@@@@%++++++*%%
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xd0,  //................+@@@@@@@@@@@@@@@@
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xcf,0xff,0xff,0xff,0xff,0xff,0xff,0xd0,  //.................+@@@@@@@@@@@@@@@
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0xef,0xff,0xff,0xff,0xff,0xff,0xd0,  //..................+%@@@@@@@@@@@@@
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x16,0xad,0xff,0xff,0xfe,0xb8,0x30,  //....................+*%@@@@@@@@%+
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x11,0x00,0x00,0x00,  //........................+++++....


};


static const uint8_t * __user_font_get_bitmap(const lv_font_t * font, uint32_t unicode_letter) {
    x_header_t *p_hd = (x_header_t*)&glyph_dsc_xbf[0];
    if( unicode_letter>p_hd->max || unicode_letter<p_hd->min ) {
        return NULL;
    }
    uint32_t unicode_offset = unicode_letter-p_hd->min;
    uint32_t *p_pos = (uint32_t *)&glyph_dsc_xbf[ sizeof(x_header_t) ];
    if( p_pos[unicode_offset] != 0 ) {
        return &glyph_dsc_xbf[ p_pos[unicode_offset]+sizeof(glyph_dsc_t) ];
    }
    return NULL;
}


static bool __user_font_get_glyph_dsc(const lv_font_t * font, lv_font_glyph_dsc_t * dsc_out, uint32_t unicode_letter, uint32_t unicode_letter_next) {
    x_header_t *p_hd = (x_header_t*)&glyph_dsc_xbf[0];
    if( unicode_letter>p_hd->max || unicode_letter<p_hd->min ) {
        return false;
    }
    uint32_t unicode_offset = unicode_letter-p_hd->min;
    uint32_t *p_pos = (uint32_t *)&glyph_dsc_xbf[ sizeof(x_header_t) ];
    if( p_pos[unicode_offset] != 0 ) {
        glyph_dsc_t * gdsc = (glyph_dsc_t*)&glyph_dsc_xbf[ p_pos[unicode_offset] ];
        dsc_out->adv_w = gdsc->adv_w;
        dsc_out->box_h = gdsc->box_h;
        dsc_out->box_w = gdsc->box_w;
        dsc_out->ofs_x = gdsc->ofs_x;
        dsc_out->ofs_y = gdsc->ofs_y;
        dsc_out->bpp   = p_hd->bpp;
        return true;
    }
    return false;
}


//Alibaba PuHuiTi Medium,,-1
//字模高度：49
//XBF字体,内部大数组
lv_font_t font_tem = {
    .get_glyph_bitmap = __user_font_get_bitmap,
    .get_glyph_dsc = __user_font_get_glyph_dsc,
    .line_height = 49,
    .base_line = 0,
};

